<template>

</template>

<script>
import { parseTime } from '@/utils/'

export default {
  name: 'minixCalendar',
  methods: {
    showCalendar(name) {
      this.arrivesShowCalendar = true
      this.calendarNanme = name
      if (name == 'rzrq' || name == 'ldrq') {
        this.minDate = new Date(2021, 11, 13)
        this.maxDate = new Date(2021, 12, 22)
      } else {
        this.minDate = new Date(2021, 0, 1)
        this.maxDate = new Date(2021, 11, 31)
      }
    },
    arriveCalenderConfirm(date) {
      this.selfUserInfo[this.calendarNanme] = parseTime(date, '{y}-{m}-{d}')
      this.arrivesShowCalendar = false
    },
    showDatetime(name) {
      this.dateTimePicker = true
      this.calendarNanme = name
    },
    datetimeConfirm(date) {
      let chooseDate = parseTime(date, '{y}-{m}-{d}')
      let now = parseTime(new Date(), '{y}-{m}-{d}')
      if (chooseDate === now) {
        this.$dialog.alert({
          message: '到达时间与返程时间不能选择为当天'
        })
        return
      }
      this.selfUserInfo[this.calendarNanme] = parseTime(date)
      this.dateTimePicker = false
    },
    datetimeFormatter(type, val) {
      if (type === 'year') {
        return `${val}年`
      } else if (type === 'month') {
        return `${val}月`
      } else if (type === 'day') {
        return `${val}日`
      } else if (type === 'hour') {
        return `${val}时`
      } else if (type === 'minute') {
        return `${val}分`
      }
      return val
    }
  }
}
</script>

<style scoped>

</style>
